﻿using System;
using System .Collections .Generic;
using System .Linq;
using System .Web;
using VehicleManagement .Models;
using VehicleManagement .Codes;

namespace VehicleManagement .ControllersServices
    {
    public class MemoryBookServices
        {

        public IList<MemoryBook> GetAllMemoryRecord()
            {
            IList<MemoryBook> lstModel = SqlMapperManager .Instance .Get() .QueryForList<MemoryBook>("SELECT_ALL_MemoryRecord" , null);
            return lstModel;
            }
        /// <summary>
        /// 根据ID查找代办事记
        /// </summary>
        /// <param name="id">代办事ID</param>
        /// <returns>MemoryBook</returns>
        public MemoryBook GetMemoryRecordByID(int id)
            {
            IList<MemoryBook> lstModel = SqlMapperManager .Instance .Get() .QueryForList<MemoryBook>("SELECT_MemoryRecord_BY_ID" , id);
            MemoryBook memorybook = lstModel .Where(u => u .MemRecordID == id) .First();
            return memorybook;

            }
        /// <summary>
        /// 插入新代办事记
        /// </summary>
        /// <param name="driver"></param>
        /// <returns></returns>
        public object CreateMemoryRecord(MemoryBook memorybook)
            {
            return SqlMapperManager .Instance .Get() .Insert("INSERT_MemoryRecord" , memorybook);
            }

        /// <summary>
        /// 修改代办事记
        /// </summary>
        /// <param name="driver"></param>
        /// <returns></returns>
        public int EditMemoryRecord(MemoryBook memorybook)
            {
            int row = SqlMapperManager .Instance .Get() .Update("UPDATE_MemoryRecord" , memorybook);
            return row;
            }
        /// <summary>
        /// 删除代办事记
        /// </summary>
        /// <param name="id">代办事记ID</param>
        /// <returns></returns>
        public int DeleteMemoryRecord(int id)
            {
            int i = SqlMapperManager .Instance .Get() .Delete("DELETE_MemoryRecord" , id);
            return i;
            }
        }
    }